<?xml version="1.0"?>
<!DOCTYPE xsl:stylesheet [
  <!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  <!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#">
  <!ENTITY dc "http://purl.org/dc/elements/1.1/">
  <!ENTITY dcterms "http://purl.org/dc/terms/">
  <!ENTITY foaf "http://xmlns.com/foaf/0.1/">
  <!ENTITY a "http://xmlns.heustics.org/schema/myelin/0.1/">
  <!ENTITY m "http://xmlns.heustics.org/ontology/myelin/0.1/">
]>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:a="http://xmlns.heustics.org/schema/myelin/0.1/"
  xmlns:l="http://xmlns.heustics.org/schema/i18n/0.1/"
  xmlns:o="&a;basic#"
  xmlns:b="&a;base#"  
  xmlns:sess="http://xmlns.heustics.org/xslt/ext/session/0.1/"
  extension-element-prefixes="sess"
  exclude-result-prefixes="xsl sess a l o b"
>
  <!-- xsl:import href="base.xslt"/ -->    
  <xsl:variable name="o:l10n" select="a:get-l10n('&a;basic')"/>
  
  <xsl:template match="a:methods" mode="a:main-actions"/>
    
  <xsl:template match="a:head" mode="a:main-head">
    
    <div id="main-actions" class='page-section actions actions-section'>
      <xsl:apply-templates mode="a:main-actions"/>
      <div class='spacer'/>
    </div>  
    
    <div id='main-header' class='page-section header-section'>      
      <xsl:apply-templates mode="a:page-header"/>
      <div class="spacer"/>
    </div> 
    
    <div id="main-nav" class='page-section nav-section'>
      <xsl:apply-templates mode="a:main-nav"/>
      <div class="spacer"/>
    </div>
    
  </xsl:template>
     
  <xsl:template match="a:nav" mode="a:main-nav">
    <xsl:param name="l10n" select="$o:l10n/*[@name='navigation']/*"/>
    <div class="navigation">  
      <div id='main_link' class="nav">
        <a href="{a:format-root-action()}">
          <xsl:value-of select="$l10n[@key='main']"/>
        </a>
        <div class="spacer"/>
      </div>
      <!-- causes caching problems xsl:choose>
        <xsl:when test="$a return-to!=$a:current-url-wo-ext">
          <div id='return-back' class="nav parents">
            <a href="{a:format-url(a:format-resource-extension($a return-to))}">
              <xsl:value-of select="$l10n[@key='return-back']"/>
            </a>
            <div class="spacer"/>
          </div>
        </xsl:when>
        <xsl:when test="$a:return-action!=$a:action and not(a:is-root($return-to)) and (($a:standalone-service and $a:return-action!='view') or not($a:standalone-service))">
          <div id='return-back' class="nav parents">
            <a href="{a:format-url(a:format-resource-extension($a return-to))}">
              <xsl:value-of select="$l10n[@key='return-back']"/>
            </a>
            <div class="spacer"/>
          </div>
        </xsl:when>
      </xsl:choose -->  
      <xsl:apply-templates mode="a:nav"/>
    </div>    
  </xsl:template>
  
  <xsl:template match="a:parents[*[@node-id!=$a:config/@root-id]]|a:node-groupings[*]" mode="a:nav">
    <xsl:param name="nav-l10n" select="$o:l10n/l:context[@name='navigation']/*"/>
    <xsl:param name="key" select="local-name()"/>
    <div class="nav {$key}"> 
      <div class="node">   
        <div class='key'>       
          <h3>
            <xsl:value-of select="$nav-l10n[@key=$key]"/>
          </h3>
          <div class='spacer'/>
        </div>
        <div class='value'>      
          <ul>
            <xsl:for-each select="*">
              <li class='parent'>
                <a href='{a:format-url(a:public-url(@uri))}' title='{@tag}'>
                  <xsl:value-of select='@title'/>
                </a>
              </li>
            </xsl:for-each>        
          </ul>
          <div class="spacer"/>
        </div>
      </div>      
      <div class="spacer"/>        
    </div>
  </xsl:template>    
  
  <xsl:template match="a:account" mode="a:main-actions">
    <xsl:param name="config" select="$a:config"/>
    <div id='search' class="box action">  
      <xsl:apply-templates select="a:node-acls" mode="a:search-form">
        <!-- xsl:with-param name="config" select="$config"/>
        <xsl:with-param name="account" select="."/ -->
        <xsl:with-param name="no-referrer" select="1"/>
      </xsl:apply-templates>
    </div>
    <!-- xsl:if test="$config/@show-anonymous-profile" -->
      <div id='profile-actions' class='box action'>
        <xsl:variable name="profile-l10n" select="$o:l10n/l:context[@name='profile-actions']/*"/>
        <dl>
          <dt>
            <xsl:value-of select="$profile-l10n[@key='profile']"/>
          </dt>
        </dl>
        <div class="body">
          <div class="wrapper">
            <xsl:apply-templates select="a:profile" mode="a:actions">
              <xsl:with-param name="profile-l10n" select="$profile-l10n"/>
            </xsl:apply-templates>
          </div>
          <div class="spacer profile-body-spacer"/>
        </div>      
        <div class="spacer profile-action-spacer"/>
      </div>
    <!-- /xsl:if -->
  </xsl:template>
  
  <xsl:template match="a:account[@logged-in]" mode="a:main-actions">
    <xsl:param name="config" select="$a:config"/>
    <div id='search' class="box action">   
      <xsl:apply-templates select="a:node-acls" mode="a:search-form">
        <xsl:with-param name="config" select="$config"/>
        <xsl:with-param name="account" select="."/>
      </xsl:apply-templates>
    </div>
    <div id='profile-actions' class='box action'>
      <xsl:variable name="profile-l10n" select="$o:l10n/l:context[@name='profile-actions']/*"/>
      <dl>
        <dt>
          <xsl:value-of select="$profile-l10n[@key='profile']"/>
        </dt>
      </dl>
      <div class="body">
        <div class="wrapper">
          <xsl:apply-templates select="a:profile" mode="a:actions">
            <xsl:with-param name="profile-l10n" select="$profile-l10n"/>
          </xsl:apply-templates>
        </div>
        <div class="spacer profile-body-spacer"/>
      </div>      
      <div class="spacer profile-action-spacer"/>
    </div>
  </xsl:template>
      
  <xsl:template match="a:profile" mode="a:actions">
    <xsl:param name="profile-l10n" select="$o:l10n/l:context[@name='profile-actions']/*"/>           
    <div id='profile-logged-in-as'>
      <span><xsl:value-of select="$profile-l10n[@key='guest-user']"/></span>
      <div class="spacer"/>  
    </div>  
    
    <div id='profile-preferences'>
      <xsl:choose>
        <xsl:when test="a:is-not-action('edit-preferences')">   
          <a href="{a:format-root-action('edit-preferences')}&amp;no-referrer=1">
            <xsl:value-of select="$profile-l10n[@key='edit-preferences']"/>
          </a>
        </xsl:when>
        <xsl:otherwise>
          <span>
            <xsl:value-of select="$profile-l10n[@key='edit-preferences']"/>
          </span>
        </xsl:otherwise>  
      </xsl:choose>
      <div class="spacer"/>
    </div>  
    
    <div id='profile-login'>
      <xsl:choose>
        <xsl:when test="a:is-not-action('login')">
          <a href="{a:format-url-full-secure(a:format-root-action('login'))}&amp;no-referrer=1">
            <xsl:value-of select="$profile-l10n[@key='login']"/>
          </a>
        </xsl:when>
        <xsl:otherwise>
          <span>
            <xsl:value-of select="$profile-l10n[@key='login']"/>
          </span>
        </xsl:otherwise>    
      </xsl:choose>
      <div class="spacer"/>
    </div>  
  </xsl:template>  
  
  <xsl:template match="a:profile[@agent-id]" mode="a:actions">
    <xsl:param name="profile-l10n" select="$o:l10n/l:context[@name='profile-actions']/*"/>    
    
    <div id='profile-logged-in-as'>
      <span><xsl:value-of select="@nick"/></span>
      <div class="spacer"/>
    </div>  
     
    <!-- xsl:if test="@domain-id and (a:is-not-current-node(@domain-id) or a:is-not-action('create-user-profile'))">
      <div id='profile-view'>       
        <a href="{a:format-request('create-user-profile',a:public-url(@domain-id))}">
          <xsl:value-of select="$profile-l10n[@key='create-user-profile']"/>
        </a>     
      </div>
    </xsl:if -->
    
    <div id='profile-logoff'>
      <a href="{a:format-url-ext(
        a:format-url-ext(
          a:format-root-action('login'),
          'event','logoff'
        ),
        'logoff','logoff')}&amp;no-referrer=1">
        <xsl:value-of select="$profile-l10n[@key='logoff']"/>
      </a>
      <div class="spacer"/>
    </div>
  </xsl:template>      
  
  <xsl:template match="a:profile[@node-id]" mode="a:actions">
    <xsl:param name="profile-l10n" select="$o:l10n/l:context[@name='profile-actions']/*"/>  
    <xsl:variable name="node-url" select="a:public-url(@uri)"/>         
    <div id='profile-logged-in-as'>
      <span><xsl:value-of select="@nick"/></span>
      <div class="spacer"/>    
    </div>    
    <div id="profile-view">
      <xsl:choose>
        <xsl:when test="a:is-not-current-node(@node-id) or a:is-not-action('view')">
          <a href="{a:format-url($node-url,'view')}?no-referrer=1">
            <xsl:value-of select="$profile-l10n[@key='view-profile']"/>
          </a>     
        </xsl:when>
        <xsl:otherwise>
          <span>
            <xsl:value-of select="$profile-l10n[@key='view-profile']"/>
          </span>
        </xsl:otherwise>
      </xsl:choose>
      <div class="spacer"/>
    </div>
    
    <div id='profile-preferences'>
      <xsl:choose>
        <xsl:when test="a:is-not-current-node(@node-id) or a:is-not-action('edit-preferences')">
          <a href="{a:format-url($node-url,'edit-preferences')}&amp;no-referrer=1">
            <xsl:value-of select="$profile-l10n[@key='edit-preferences']"/>
          </a>
        </xsl:when>
        <xsl:otherwise>
          <span>
            <xsl:value-of select="$profile-l10n[@key='edit-preferences']"/>
          </span>
        </xsl:otherwise>
      </xsl:choose>
      <div class="spacer"/>
    </div>  
    
    <div id='profile-login'>
      <a href="{a:format-url-ext(
        a:format-url-ext(a:format-root-action('login'),
          'event','logoff'),
        'logoff','logoff')}&amp;no-referrer=1">
        <xsl:value-of select="$profile-l10n[@key='logoff']"/>
      </a>
      <div class="spacer"/>
    </div>    
  </xsl:template> 
  
</xsl:stylesheet>

